home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 84 / MacAddict_084_2003_08.iso / pc / Software / Utilities / Safari Enhancer 2.0.1.dmg / Safari Enhancer.app / Contents / Resources / c2ie.pl next >
Perl Script  |  2003-05-25  |  1KB  |  44 lines

  1. #!/usr/bin/perl
  2.  
  3. ##
  4. # c2ie.pl
  5. # convert chimera bookmarks to ie bookmark format
  6. #
  7.  
  8.  
  9. use Text::ParseWords;
  10.  
  11. # we're following IE's lousy html here, don't blame me just cause there's no HEAD or BODY tags.s
  12. print( "<HTML>\n<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=x-mac-roman\">\n<TITLE>Favorites</TITLE>\n\n<H1 >Favorites</H1>\n\n<DL><p>\n\n");
  13.  
  14.  
  15. while( <> )
  16. {
  17.     chomp;
  18.     @entries = &parse_line( '[<>]+', 0, $_ );
  19.     foreach $line ( @entries )
  20.     {
  21.         # empty folders are listed <.../>, and have no separate close tag 
  22.         if( $line =~ m/folder name=(.*?)(?: (?:open|type)=(?:.*))*\/$/ )
  23.         {
  24.             print( "\t<DT><H3 OBJECT_TYPE=\"LINK\">$1</H3>\n\t<DL>\n\t</DL>\n" );
  25.         }    
  26.         # folders with something in them have > not /> at the end, and later a </folder>
  27.         elsif( $line =~ m/folder name=(.*?)(?: (?:open|type)=(?:.*))*$/ )
  28.         {
  29.             print( "\t<DT><H3 OBJECT_TYPE=\"LINK\">$1</H3>\n\t<DL>\n" );
  30.         }
  31.         # close folder
  32.         elsif( $line =~ m/\/folder/ )
  33.         {
  34.             print( "\t</DL>\n\n" );
  35.         }
  36.         # actual bookmark entry
  37.         elsif( $line =~ m/bookmark name=(.*) href=(.*)\// )
  38.         {
  39.             print( "\t\t<DT><A HREF=\"$2\" OBJECT_TYPE=\"LINK\">$1</A>\n" );
  40.         }
  41.     }
  42. }
  43.  
  44. print( "\n\n</DL></HTML>\n" );